<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" >
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >
<link href="/admins/css/yundan.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/boxy/js/jquery.boxy.js"></script>
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/js/boxy/js/jquery.boxy.js"></script>
<link href="/js/boxy/css/boxy.css" media="screen" rel="stylesheet" type="text/css" >  
<script type="text/javascript">
      $(function() {
            window.alert = Boxy.alert;
            window.confirm = Boxy.confirm;
      });
</script>
<style>
      .timezdy{float:left;height:30px;border-right:#eee solid 1px;width:100px;position:relative;z-index:1500;color:#666;}
      .search1{float:left;width:80px;height:30px;text-align: center;padding: 5px;}
      .search{border:#ddd solid 1px;float:left;width:280px;height:30px;background:#fff;}
      .search2{border:#ddd solid 1px;float:left;width:160px;height:30px;background:#fff;}
      .soubox{position:relative;z-index:1;float:left;}
      .soubox input{border:0;padding:5px 5px;float:left;height:20px;line-height:20px;width:240px;background:#fff;font-size:14px;}
      .soubox label{position:absolute;z-index:2;top:0;left:0;line-height:30px;padding-left:6px;font-size:14px;color:#bbb;cursor:inherit;}
      .search a{float:left;text-indent:-10000px;width:30px;height:30px;}
      .search2 a span{background:url(/admins/images/ico.png) no-repeat -90px 0;height:14px;width:14px;cursor:pointer;float:left;margin:8px 0 0 8px;display:inline;}
      .search a:hover span{background-position:-104px 0;}
      .xstype{float:left;line-height:30px;width:330px;font-size:14px;margin-left: 20px;}
      .xstype label{float:left;line-height:32px;}
      .xstype li{float:left;width:55px;margin-left: 10px;}
      .xstype li a{width:30px;height:30px;float:left;text-align:center;border:#ddd solid 1px;background:#fff;}
      .xstype li a:hover{background:#eee;}
      .xstype .xson a,.xianshi .xson a:hover{background:#f90;color:#fff;border:#f60 solid 1px;}
</style>
<div class="admin_nrtop">
      <div class="ad_search">
            <form action=""  method="get" style="margin:0px" id="form1">
                  <div class="search1">类型：</div>
                  <div class="search2">
                        <div class="soubox">
        <!--                    <input type="text" id="quick" name="quick" value="" placeholder="输入任务名称/任务描述等"/>-->
                              <input type="hidden" id = "style" value = "<?php echo $this->quick ? $this->quick : ""; ?>" placeholder="输入事项类型/名称"/>
                              <select id="quick" name="quick" style="margin-top:0px;width:160px;height:30px;float:right;border: 0px solid #ddd;">
                                    <option value="">全部</option>
                                    <?php foreach ($this->objtype as $key=>$val){?>
                                    <option value='<?=$val->id?>'><?=$val->name?></option>
                                    <?php }?>
                              </select>
                              <input type="hidden" id="timescope" name="timescope" value="<?php echo $this->timescope ? $this->timescope : ""; ?>" />
                              <input type="hidden" id="searchType" name="searchType" value="<?php echo $this->searchType === "" ? "" : $this->searchType; ?>" />
                        </div>
                  </div>
                  <div style="float:left;width:235px; ">
                        <div style="margin-left: 20px; height: 30px;">
                               <div class="search1">范围选择：</div>
                               <div class="timezdy" style="border:1px solid #ddd;background: #fff;">
                                    <div class="timeselect2">
                                          <span><?php
                                                if ($this->timescope) {
                                                      switch ($this->timescope) {
                                                            case "today":
                                                                  echo "今天";
                                                                  break;
                                                            case "week":
                                                                  echo "七天内";
                                                                  break;
                                                            case "month":
                                                                  echo "一个月内";
                                                                  break;
                                                            case "threemonth":
                                                                  echo "三个月内";
                                                                  break;
                                                            case "year":
                                                                  echo "一年内";
                                                                  break;
                                                            default:
                                                                  echo "全部";
                                                                  break;
                                                      }
                                                } else {
                                                 echo '全部';       
                                                }
                                                ?>
                                          </span><i></i>
                                    </div>
                                    <div class="timeslelct_xl" style="display:none;">
                                          <ul>
                                                <li><a href="javascript:setstart('whow')">全部</a></li>
                                                <li><a href="javascript:setstart('today')">今天</a></li>
                                                <li><a href="javascript:setstart('week')">7天内</a></li>
                                                <li><a href="javascript:setstart('month')">一个月内</a></li>
                                                <li><a href="javascript:setstart('threemonth')">三个月内</a></li>
                                                <li><a href="javascript:setstart('year')">今年</a></li>
                                          </ul>
                                    </div>
                              </div>
                              
                        </div>
                  </div>
                  <div class="xstype">
                        <label>状态：</label>
                        <ul>
                              <label><li class="xson" ><input class='invoice' name="searchType" type="radio"<?php if (!$this->status) {
                                                      echo "checked=''";
                                                } ?> value="0">全部</li></label>
                              <label><li class="xson" ><input class='invoice' name="searchType" type="radio"<?php if ($this->status == 1) {
                                                      echo "checked=''";
                                                } ?> value="1">未开始</li></label>
                              <label><li class="xson" ><input class='invoice' name="searchType" type="radio"<?php if ($this->status == 2) {
                                                      echo "checked=''";
                                                } ?> value="2">进行中</li></label>
                              <label><li class="xson" ><input class='invoice' name="searchType" type="radio"<?php if ($this->status == 3) {
                                                      echo "checked=''";
                                                } ?> value="3">已完成</li></label>
                        </ul>
                  </div>
                  <div class="search">
                        <div class="soubox">
                            <input type="text" id = "title" name="title" value = "" placeholder="输入事项名称/创建人"/>
                        </div>
                        <a href="javascript:$('#form1').submit();"><span>搜索</span></a>
                    </div>
            </form>
      </div>
</div>
<div  class="biaoge">
      <div class="biaotbody">
            <table >
                  <tr>
                        <th class="li6" style="text-align:center">
                              日期
                        </th>
                        <th class="li6" >
                              <div class='biaoxiala'>
                                    <div class="lixiala">
                                          <span>类型</span><i></i>
                                    </div>
                                    <div class="biaoxllb" style="display:none;">
                                          <ul>
                                                <?php foreach ($this->objtype as $key=>$val){?>
                                                <li><a href="javascript:setchannel('<?=$val->id?>')"><?=$val->name?></a></li>
                                                <?php }?>
                                          </ul>
                                    </div>
                              </div>
                        </th>
                        <th class="li6" >
                              关联单号
                        </th>
                        <th class="li6" >
                              创建人
                        </th>
                        <th class="li6" >
                              指定人
                        </th>
                        <th class="li10">
                              标题
                        </th>
                        <th class="li6">
                              <div class='biaoxiala'>
                                    <div class="lixiala">
                                          <span>状态</span><i></i>
                                    </div>
                                    <div class="biaoxllb" style="display:none;">
                                          <ul>
                                                <li><a href="javascript:setstatus(1)">未开始</a></li>
                                                <li><a href="javascript:setstatus(2)">进行中</a></li>
                                                <li><a href="javascript:setstatus(3)">已完成</a></li> 
                                          </ul>
                                    </div>
                              </div>
                        </th>
                        <th class="li10" style="text-align:center;">
                              操作
                        </th>
                  </tr>
            </table>
      </div>
      <div class="table" style='margin-top:0px;'>
             <table>
<?php
if ($this->objlist) {
      foreach ($this->objlist as $key => $Item) {
            ?>
                        <tr>
                              <td class="li6" align="center"><?= $Item->dateCreated ?></td>
                              <td class="li6" >
                                    <div class="yubm">
                                    <?php echo $Item->ObjectName->name ?>
                                          </a></div>
                              </td>
                              <td class="li6" ><?php
                                    if ($Item->objectId) {
                                          echo"<div class='yubm'><a href=".'/admini/'.Application_Model_DomainobjectType::getTypeItem($Item->objectType).$Item->objectId.">";
                                          echo $Item->objectId . '</a></div>';
                                    } else {
                                          echo '— —';
                                    }
                                    ?></td>
                              <td class="li6" ><?php echo $Item->creator// echo $Item->UserName?$Item->UserName->nikename:''; ?></td>
                              <td class="li6" ><?php echo $Item->operator ? $Item->operator : "未指定"; ?></td>
                              <td class="li10"><?php echo $Item->title; ?></td>
                              <td class="li6" ><?php echo $Item->ObjectStatus; ?>
                              </td>
                              <td class="li10">
                                    <?php 
                                    $statusvalue = $Item->EqualName;
                                    if($statusvalue){?>
                                    <table style="border: #d4dae2 solid 0px;">
                                          <tr>
                                                <th width="25%" style="text-align:center;">
                                          <div class="yubm">
                                                <?php
                                                if ($Item->status == Application_Model_TodoTask::Object_Add && ($statusvalue ==Application_Model_TodoTask::Name_third ||$statusvalue ==Application_Model_TodoTask::Name_first)) {
                                                      echo "<a href='{$this->list}status/{$Item->id}'>";
                                                      echo'开始</a>';
                                                } else if ($Item->status == Application_Model_TodoTask::Object_Appoint && ($statusvalue ==Application_Model_TodoTask::Name_third ||$statusvalue ==Application_Model_TodoTask::Name_first)) {
                                                      echo "<a href='{$this->list}status/{$Item->id}'>";
                                                      echo'完成</a>';
                                                } else {
                                                      echo'';
                                                }
                                                ?>
                                          </div>
                                          </th>
                                          <th width="25%" style="text-align:center;">
                                          <div class="yubm">
                                                <?php
                                                if (($Item->status == Application_Model_TodoTask::Object_Add && $statusvalue)||($Item->status == Application_Model_TodoTask::Object_Appoint && ($statusvalue ==Application_Model_TodoTask::Name_third|| $statusvalue ==Application_Model_TodoTask::Name_first))) {
                                                      echo "<a href='javascript:void(0)'class='distribution' name='{$Item->id}'>";
                                                      echo'分配</a>';
                                                } else {
                                                      echo'';
                                                }
                                                ?>
                                          </div>
                                          </th>
                                          <th width="25%" style="text-align:center;">
                                          <div class="yubm">
                                                <?php if($statusvalue&&$Item->operator){echo'<a href=/admini/todotask/edit?id='.$Item->id.'>详情</a>';}?>
                                          </div></th>
                                          <th width="25%" style="text-align:center;">
                                          <div class="yubm">
                                                <a class="deleId" name="<?= $Item->id ?>" href="javascript:void(0)">删除</a>
                                          </div>
                                          </th>
                                          </tr>
                                    </table>
                                    <?php }else{
                                          echo'<div class="yubm" style="text-align:center;">';
                                          echo'<a href=/admini/todotask/detail/id/'.$Item->id;
                                          echo'>查看详细</a>';
                                          echo'</div>';
                                    }?>
                              </td>
<!--                              <td class="li505">
                                <div class="lixlnav">
                                    <a class="xlnavxq" href="/admini/todotask/detail/id/{$Item->id}" >详情</a>
                                    <div class="xlnavlistbox" >
                                        <a class="xlnavsj" href="javascript:void(0)"><i></i></a>
                                        <div class="xlnavlist" style="display:none;">
                                            <ul>
                                                <li><div class="yubm">
                                                <?php
                                                if ($Item->status == Application_Model_TodoTask::Object_Add && ($statusvalue ==Application_Model_TodoTask::Name_third ||$statusvalue ==Application_Model_TodoTask::Name_first)) {
                                                      echo "<a href='{$this->list}status/{$Item->id}'>";
                                                      echo'开始</a>';
                                                } else if ($Item->status == Application_Model_TodoTask::Object_Appoint && ($statusvalue ==Application_Model_TodoTask::Name_third ||$statusvalue ==Application_Model_TodoTask::Name_first)) {
                                                      echo "<a href='{$this->list}status/{$Item->id}'>";
                                                      echo'完成</a>';
                                                } else {
                                                      echo'';
                                                }
                                                ?>
                                          </div></li>
                                                <li><div class="yubm">
                                                <?php
                                                if (($Item->status == Application_Model_TodoTask::Object_Add && $statusvalue)||($Item->status == Application_Model_TodoTask::Object_Appoint && ($statusvalue ==Application_Model_TodoTask::Name_third|| $statusvalue ==Application_Model_TodoTask::Name_first))) {
                                                      echo "<a href='javascript:void(0)'class='distribution' name='{$Item->id}'>";
                                                      echo'分配</a>';
                                                } else {
                                                      echo'';
                                                }
                                                ?>
                                          </div></li>
                                                <li><div class="yubm">
                                                <?php if($statusvalue){echo'<a href=/admini/todotask/edit?id='.$Item->id.'>修改</a>';}?>
                                          </div></li>
                                                <li><div class="yubm">
                                                <a class="deleId" name="<?= $Item->id ?>" href="javascript:void(0)">删除</a>
                                          </div></li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>
                            </td>-->
                        </tr>
                  
            <?php
                  }
            } else {
                  echo '<div class="tablebox"></div>';
            }
            ?>
                        </table>
      </div>
</div>
<div class="tanchuang" style="display:none;">
      <div class="nui-msgbox">
            <div class="nui-msgbox-hd" id="uuchInterior" style="">待办事项分配</div>
            <a class="nui-msgbox-close" title="关闭"><b></b></a>
      </div>
      <div class="wenti_box" id="interiorRemark" style="padding-top: 20px;">
            <form method="post" action="" id="formremark">
                  <div class="qudao">
                        <dl>
                              <dt>指派给：</dt>
                              <dd>
                                    <select id="distribut" name="distribut" style="font-size: 14px; line-height: 24px;">
                                          <?php
                                          foreach ($this->worker as $value) {
                                                echo "<option value={$value->nikename}>" . $value->nikename . "</option>";
                                          }
                                          ?>
                                    </select>
                              </dd>
                        </dl>
                        <dl>
                              <dt></dt>
                              <dd style="padding-left: 80px;"><a href="#" class="anvbotton5" id="start_point"><span>确定</span></a></dd>
                        </dl>
                  </div>
            </form>
            <div id="pointtrack">
            </div>
      </div>
      <input id="getobjid" type="hidden" value=""/>
</div>
<div class="toolbar">
      <div class="qunx">  
            <ul>
                  <li><a class="anvbotton" href='/admini/todotask/add' id="printOut" name="printOut"><span>添加事项</span></a></li>
<!--                        <li><a class="anvbotton4" href="javascript:void(0)" id="ckall" name="ckall"><span></span></a></li>-->
            </ul>
      </div>
</div>
<?php echo $this->name ?>
<div class="toolbar">
<?php echo $this->partial('paging.phtml', array("pages" => $this->objAll, "pamas" => "name=" . $this->name)); ?>
</div>
<script type="text/javascript">
      $(document).ready(function() {
            var option = $("#style").val();
//            alert(option);
            $("#quick option[value =" + option + " ]").attr("selected","true");
            $("#quick").change(function(){
                  $("#form1").submit();
            });
            $(".distribution").click(function() {
                  var com = $(this).attr("name");
                  $('.tanchuang').attr("style", "display:block;");
                  $('#getobjid').val(com);
                  var url = '/admini/todotask/track?objectId=' + com;
                  $("#pointtrack").load(url);
                 
            });
             $("#start_point").click(function() {
                   var com = $('#getobjid').val();
                        $.post(
                                "/admini/todotask/index/",
                                {
                                      objid: com,
                                      objoperator: $("#distribut").val()
                                },
                        function(data) {
                              window.location.href="/admini/todotask/index/";
                        });
                  });

            $(".nui-msgbox-close").click(function() {
                  $('.tanchuang').attr("style", "display:none;");
            });
            $(".dian").mouseenter(function() {
                  $(this).next("div").attr("style", "display:block;");
            });
            $(".bzloading").mouseleave(function() {
                  $(".bzloading .bzxiangbox").attr("style", "display:none;");
            });
            $(".deleId").click(function() {
                  var name = $(this).attr("name");
                  confirm("确定删除该事项吗？", function() {
                        location.href = '/admini/todotask/dele?id=' + name;
                  });
            });
            $('.soubox label').click(function() {
                  $(this).parent().find('input').focus();
            });
            $(".timezdy").click(function() {
                  $(".timezdy .timeselect2").attr("class", "timeselect2 timeon");
                  $(".timeslelct_xl").show();
            });
            $(".timezdy").mouseleave(function() {
                  $(".timeselect2").attr("class", "timeselect2");
                  $(".timeslelct_xl").hide();
            });
            $("#stime").click(function() {
                  $(this).attr("class", "timeselect t_on");
                  WdatePicker({el: 'stimeval', vel: 'starttime', onpicked: function() {
                              $("#stime,#etime").attr("class", "timeselect");
                        }});
            });
            $("#etime").click(function() {
                  $(this).attr("class", "timeselect t_on");
                  WdatePicker({el: 'etimeval', vel: 'endtime', onpicked: function() {
                              $("#stime,#etime").attr("class", "timeselect");
                        }});
            });

            $(".lixiala").click(function() {
                  $(".lixiala").attr("class", "lixiala");
                  $(".lixiala").next("div").hide();

                  $(this).attr("class", "lixiala bton");
                  $(this).next("div").show();
            });
            $(document).bind("click", function(e) {
                  var target = $(e.target);
                  if (target.closest(".biaoxiala").length == 0) {
                        $(".lixiala").attr("class", "lixiala");
                        $(".lixiala").next("div").hide();
                  }
                  if (target.closest("#stime").length == 0) {
                        $("#stime").attr("class", "timeselect");
                  }
                  if (target.closest("#etime").length == 0) {
                        $("#etime").attr("class", "timeselect");
                  }
            });

      });
      $(".invoice").click(function() {
            var con= this.value;
            $(".invoice").val(con);
            $('#form1').submit();
      });
      function setstart(start)
      {
            $(".soubox #timescope").val(start);
            $(".timeslelct_xl").attr("style", "display:none;");
            $('#form1').submit();
      }
      function setchannel(start)
      {
            $("#quick").val(start);
            $(".biaoxllb").attr("style", "display:none;");
            $('#form1').submit();
      }
      function setstatus(start)
      {
            $(".invoice").val(start);
            $(".biaoxllb").attr("style", "display:none;");
            $('#form1').submit();
      }
      $(".xlnavsj").live("mousemove",function(){
        $(this).next("div").attr("style","display:block;");
      });
      $(".lixlnav").mouseleave(function(){
        $(".xlnavsj").next("div").attr("style","display:none;");
      });
</script>
